package cn.silver.module.message.service.impl;

import cn.silver.framework.core.utils.MapstructUtils;
import cn.silver.framework.log.event.OperEvent;
import cn.silver.framework.message.event.NoticeEvent;
import cn.silver.framework.mybatis.service.impl.BusServiceImpl;
import cn.silver.module.message.bean.NoticeBean;
import cn.silver.module.message.domain.MsgNotice;
import cn.silver.module.message.mapper.MsgNoticeMapper;
import cn.silver.module.message.param.NoticeParam;
import cn.silver.module.message.service.IMsgNoticeService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * 公告 服务层实现
 *
 * @author Lion Li
 */
@Service
@RequiredArgsConstructor
public class MsgNoticeServiceImpl extends BusServiceImpl<MsgNoticeMapper, MsgNotice, NoticeParam, NoticeBean> implements IMsgNoticeService {

    @Override
    public void init() {

    }

    /**
     * 操作日志记录
     *
     * @param event 操作日志事件
     */
    @Async
    @EventListener
    public void sendNotice(NoticeEvent event) {
        NoticeBean bean = MapstructUtils.convert(event, NoticeBean.class);
        // 远程查询操作地点
        this.insert(bean);
    }
}
